﻿<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
include 'data/weby.php';
include('data/sdk/class.rc4crypt.php');//引入SDK文件,方便快捷！
$key = "dnqyyz"; //KEY必须与易语言同步
$rc4 = new Crypt_RC4();//初始化SDK
$rc4 -> setKey($key);//设置RC4密匙
$username=$_GET["username"];
$domain=$_GET["domain"];
$qq=$_GET["qq"];
$ycp=$_GET["ycp"];
$km=getkm(12);
$nowtime=time();
$pass=$_GET["pass"];




if($_GET[submit]=="确定注册")
{
	$sql="select * from products where cp='$ycp'";
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
		while ($row=mysqli_fetch_assoc($result)) {
			$kf = $row['kf'];
			$qt = $row['qt'];	
	}}
	if($kf != 1 or $qt !=1){echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">此产品未开放注册<br>请联系客服</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");
	die();
	}
	else
		$sql="select * from authorize where domain='$domain' and ycp='$ycp'";
		$query=mysqli_query($con,$sql);
		$rows = mysqli_num_rows($query);
		$row=mysqli_fetch_assoc($query);
		if($rows > 0)
		{
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">此产品中，该账号已存在！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");
		die();
		}
		else
	require_once "data/Smtp.class.php";
    $mailtype = "HTML";//邮件格式（HTML/TXT）,TXT为文本邮件
    $smtp = new Smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
    $smtp->debug = false;//是否显示发送的调试信息
		$ucl = '*ycp='.$ycp.'*username='.$username.'*domain='.$domain.'*pass='.$pass.'*qq='.$qq;
		$econtent = '请点击下方链接完成注册验证<br>http://'.$_SERVER['HTTP_HOST'].'/self-zc.php?submit=1'.base64_encode($rc4->encrypt($ucl));
		$toemail = $qq.'@qq.com';
		$etitle = $title.'-注册验证';
		$state = $smtp->sendmail($toemail, $smtpusermail, $etitle, $econtent, $mailtype);
		if($state!="")
		{echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">注册链接已发送到您的QQ邮箱<br>请及时点击链接完成注册<br>如果失效请重新注册</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");
	die();}
		else {echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">在注册链接发送遇到问题<br>请联系客服处理<br>".$arr['message']."</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");
	die();}
}

if($_GET[submit]!="确定注册" and $_GET[submit]!=null)
{	
	$dddata = substr($_GET[submit],1);
	$shuju = $rc4->decrypt(base64_decode($dddata));
	$shuju = str_replace("*","&",$shuju);
	$shuju1 = 'http://'.$_SERVER['HTTP_HOST'].'/self-zc.php?submit=1'.$shuju;
	$data = getcs($shuju1);

	$ycp = $data['ycp'];
	$username = $data['username'];
	$domain = $data['domain'];
	$pass = $data['pass'];
	$qq = $data['qq'];
	$dl = $data["dl"];
	if($dl == ''){$dl="普通用户";}else{$dl=$data["dl"];}
	$km = getkm(12);
	
		$sql="select * from authorize where domain='$domain' and ycp='$ycp'";
		$query=mysqli_query($con,$sql);
		$rows = mysqli_num_rows($query);
		$row=mysqli_fetch_assoc($query);
		if($rows > 0)
		{
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">链接已失效！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");
		die();
		}
		else{
			$sql = "INSERT INTO `authorize` (`username`,`domain`,`pass`,  `qq`,  `time`, `syskey`, `ycp`, `dl`) VALUES ('$username','$domain','$pass',  '$qq',  'free', '$km', '$ycp', '$dl');";//添加授权
			mysqli_query($con,$sql); 
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">注册成功<br>用户名：".$username."<br>账号：".$domain."<br>密码：".$pass."<br>联系人QQ：".$qq."<br>余额：0<br>类型：免费用户<br>产品：".$ycp."<br>用户key：".$km."<br>此key非常重要，请记录下来</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'self-zc.php' });  }});</script>");	
			
			}


}


function getcs($str){//获取网址中指定参数
$data = array();
$parameter = explode('&',end(explode('?',$str)));
foreach($parameter as $val){
$tmp = explode('=',$val);
$data[$tmp[0]] = $tmp[1];
}
return $data;
}

function getkm($len = 12){//获取一串随机字符串，例如卡密、密码等
	$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	$strlen = strlen($str);
	$randstr = "";
	for ($i = 0; $i < $len; $i++) {
		$randstr .= $str[mt_rand(0, $strlen - 1)];
	}
	return $randstr;
}
?>

<?php
include 'head.php';
?>

    <title>用户注册-<?php echo $title?></title>
<link rel="shortcut icon" href="<?php echo $route?>img/LightCloud.png" type="image/x-icon" />
    <!-- Bootstrap core CSS -->
    <link href="<?php echo $route?>css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo $route?>css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="<?php echo $route?>font-awesome/css/font-awesome.css"  rel="stylesheet"/>
    <!-- Custom styles for this template -->
    <link href="<?php echo $route?>css/style.css"  rel="stylesheet">
    <link href="<?php echo $route?>css/style-responsive.css" rel="stylesheet"/>
    <!--toastr-->
    <link href="<?php echo $route?>toastr-master/toastr.css" rel="stylesheet" type="text/css"/>
    <script language="JavaScript" src="<?php echo $route?>js/jquery-1.7.2.min.js"></script>
    <script language="JavaScript" src="<?php echo $route?>js/function.js"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="<?php echo $route?>js/html5shiv.js" ></script>
    <script src="<?php echo $route?>js/respond.min.js" ></script>
    <![endif]-->
	<style>
	body{
		margin: 0 auto;
		text-align: center;
	}
	.container {
	  max-width: 580px;
	  padding: 15px;
	  margin: 0 auto;
	}
	.hzhz{
		float: left;
	}
	.bzbz {
	color: #31708f;
	background-color: rgba(217, 237, 247, 0.73);
	border-color: #bce8f1;

	padding: 15px;
	margin-bottom: 20px;
	border: 1px solid transparent;
	border-radius: 3px;
	}
	.form-controltm {
	display: block;
	width: 100%;
	height: 34px;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1.42857143;
	color: #555;
	background-color: rgba(255, 255, 255, 0.48);
	background-image: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
	box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
	-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
	-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
	transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
	}

	.alert-dangergg {
	color: #a94442;
	background-color: #f2dede;
	border-color: #ebccd1;

	padding: 15px;
	margin-bottom: 20px;
	border: 1px solid transparent;
	border-radius: 4px;
	}
	</style>
</head>

<body >

<section id="container" >

    <section id="main-content">
        <section class="wrapper">
           <div class="row">
<div class="col-md-6 col-md-offset-2">
                    <!--work progress start-->
                    <section class="panel">
                        <div class="panel-body progress-panel">
                            <div class="task-progress">
                                <h1>用户注册</h1>
                                
                            </div>
                        </div>
						<div class="table  table-hover personal-task">
							<ul class="pagination"><a class="btn btn-info" href="index.php">用户查询</a> &nbsp;<a class="btn btn-primary" href="self-zc.php">用户注册</a> &nbsp;<a class="btn btn-success" href="self-km.php">卡密充值</a> &nbsp;<a class="btn btn-warning" href="<?php echo $website; ?>" target="_blank">购买卡密</a></ul>
							<div class="alert-dangergg">
                        			<?php echo $prompt; ?>	</div>
                        		 <br>
							
	 <h3 class="form-signin-heading">输入您的信息</h3>
	 <form action="self-zc.php" class="form-sign" method="get"><input type="hidden" name="self" value="6" />
	 (注册免费，请选择对应产品)<br><br>
		<div class="form-group">
                                <label for="txtDomain"></label>
                                <select name="ycp" class="form-control" >
								<option value=''>请选择要注册的产品 </option>
 									<?php 
										$sql="select * from products ORDER BY `id` DESC";
										$result=mysqli_query($con,$sql);
										if($result&&mysqli_num_rows($result)){
											while ($row=mysqli_fetch_assoc($result)) {
												if($row['qt']==1 ){
												echo "<option value='".$row['cp']."'>".$row['cp']."</option>";	}										
											}
										}
									?>   
									</select>
								</div>
		<input type="text" class="form-controltm" name="username" placeholder="请输入用户名，支持中文，必填" value="" required><br>
		 <input type="text" class="form-controltm" name="domain" placeholder="请输入账号，必填" value="" required><br>
		 <input type="text" class="form-controltm" name="pass" placeholder="请输入密码，必填" value="" required><br>
		 <input type="text" class="form-controltm" name="qq" placeholder="请输入联系人QQ，要接收邮件验证，请认真填写，必填" value="" required><br>
		 <input type="submit" name="submit" class="btn btn-danger btn-block" value="确定注册">
	 </form>
<br/>
<br/>
<br/>
<?php
include "search.php";
?>	
                        <div class="container-fluid"> 
								<a href="<?php echo $website; ?>" target="_blank" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-credit-card"></span> 购买</a> 
								<a class="btn btn-success" href="user.php">自助后台</a>
								<a class="btn btn-primary" href="user">代理后台</a>&nbsp;<a class="btn btn-danger" href="center">系统后台</a>
							<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=<?php echo $kfqq; ?>&amp;site=qq&amp;menu=yes" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-pencil"></span> 客服</a> </div>
   <p style="text-align:center"><br>&copy; Powered by <?php echo $title?></p></div>

                    </section>
                    <!--work progress end-->
                </div>
				

        </section>
    </section>
    <!--main content end-->
</section>


<!-- js placed at the end of the document so the pages load faster -->
<script src="<?php echo $route?>js/jquery.js" ></script>
<script src="<?php echo $route?>js/bootstrap.min.js" ></script>
<!--toastr-->
<script src="<?php echo $route?>toastr-master/toastr.js" ></script>

<script type="text/javascript" src="<?php echo $route?>jCryption/jquery.jcryption.3.1.0.js" ></script>


</body>
</html>
